1. Field of the Invention
The invention relates to a block decoding method and apparatus and, more particularly, to a block decoding method and apparatus capable of decoding and outputting data in a longitudinal direction.
2. Description of Related Art
Block decoding is an image compressing/decompressing technique, and JPEG decoding is one of the most popular block decoding schemes. FIG. 1 is a block diagram of a JPEG decoder 10. As shown in FIG. 1, the JPEG decoder 10 is essentially constructed by a decoding device 110, a de-zigzag arranging device 120, an inverse quantizer 130, an inverse discrete cosine transform (IDCT) device 140, a color space converter 150, a controller 160 and a memory device 170, thereby decoding a JPEG compressed image file 100 in which table data 102 and format data 103 that are associated with a compressed data datastream 101 thereof are provided. The table data 102 includes a Huffman coding table 111 and an inverse quantization table 131 such that the decoding device 110 can perform a Huffman decoding on the compressed datastream 101 in accordance with the Huffman coding table 111 when the JPEG decoder 10 decodes the compressed image file 100 to thus obtain an one-dimensional block consisting of pixels arranged in one dimension. In accordance with the JPEG standard, the de-zigzag arranging device 120 arranges the one-dimensional block into a two-dimensional block consisting of pixels arranged in two dimensions. As shown in FIG. 2, the arrows direct the sequence of pixel arrangement from the one-dimensional block to the two-dimensional block. Namely, the pixels are arranged in a directional sequence: transverse (right), diagonal (left-down), down, diagonal (right-up) and so on.
The inverse quantizer 130 performs inverse quantization on the two-dimensional block in accordance with the inverse quantization table 131 to thus obtain a two-dimensional inverse quantization block. FIG. 3 is an example of a content of the inverse quantization table 131. The IDCT device 140 converts the two-dimensional inverse quantization block from frequency domain to spatial domain. The color space converter 150 performs color conversion on the two-dimensional spatial block to thus convert its YCbCr format into a RGB format, thereby obtaining a decompressed image block similar to its source image.
The controller 160 controls the entire JPEG decoding to obtain an RGB decompressed image 200, and performs an initialization and setting on the internal registers of the devices 110, 120, 130, 140 and 150. The memory device 170 temporarily stores the JPEG compressed image file 100 and the decompressed image 200.
As cited, the JPEG decoder 10 requires sequentially decoding the blocks of the compressed datastream 101 first and then re-combines them into the complete decompressed image 200. For example, as to the decompressed image 200 represented by the picture shown in FIG. 4, the JPEG decoder 10 sequentially decodes each block 41 in a direction A (horizontal). When printing the decompressed image 200, a typical printer feeds paper in a B direction and fetches each block 41 of the decompressed image 200 in a direction C (longitudinal). Accordingly, it is seen that the JPEG decoder 10 decodes the compressed datastream 101 for obtaining every block 41 and storing them to the memory device 170 first and then fetches the decompressed image 200 in the direction C for printing it out. However, the memory device 170 is increased with higher image resolution for storing more data. For an example of the decompressed image 200 with ((M+1)×(N+1)) blocks, if every block has red, green and blue colors and requires a memory space of 8×8×3 bytes, the size of the memory device 170 required by the JPEG decoder 10 is up to ((M+1)×(N+1)×64×3) bytes, which needs a very high hardware cost.
To overcome this problem, U.S. Pat. No. 6,298,166 granted to Ratnakar, et al. for an “Image transformations in the compressed domain” records additional information about compressed blocks along with coding and compressing. However, the additional information including indexes of the compressed blocks is not necessary in the JPEG standard but provided for a special JPEG decoder. In accordance with the additional information, the JPEG decoder can decode data in the longitudinal direction and output a re-arranged and re-compressed JPEG file based on a requirement of image rotation and mirror. Such a technique requires the additional processes in coding and compressing, and this system is suitable to implement the functions of rotation and mirror in a digital image input system because it does not teach or disclose any longitudinal processing for a non-digital image input system. In addition, Ratnakar discloses the processing of image mirror and rotation in frequency domain, not in spatial domain. Further, the processing of image mirror and rotation in frequency domain tends to a theoretical study rather than implement in practice. Therefore, it is desirable to provide an improved block decoding method and apparatus to mitigate and/or obviate the aforementioned problems.